/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package magazzino.web.ricercaProdotto;

import java.util.Collection;
import javax.servlet.http.HttpServletRequest;

import to.pm.entity.catalogo.Prodotto;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author mauri
 */
public class RicercaProdottoForm extends org.apache.struts.action.ActionForm {
    
    private String nome;

    private Collection<? extends Prodotto> prodotti;

    private long id;

    public Collection<? extends Prodotto> getProdotti() {
        return prodotti;
    }

    public void setProdotti(Collection<? extends Prodotto> prodotti) {
        this.prodotti = prodotti;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public RicercaProdottoForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getNome() == null || getNome().length() < 1) {
            errors.add("nome", new ActionMessage("error.name.required"));
            // TODO: add 'error.name.required' key to your resources
        }
        return errors;
    }
}
